package com.hyh.shiyanshiguanli.service.impl;

import com.hyh.shiyanshiguanli.constant.MessageConstant;
import com.hyh.shiyanshiguanli.domain.dto.LibAddDTO;
import com.hyh.shiyanshiguanli.domain.dto.LibDTO;

import com.hyh.shiyanshiguanli.domain.dto.LibUpdateDTO;
import com.hyh.shiyanshiguanli.domain.entity.Lib;
import com.hyh.shiyanshiguanli.domain.entity.LibManager;

import com.hyh.shiyanshiguanli.domain.vo.LibVO;
import com.hyh.shiyanshiguanli.mapper.LibMapper;
import com.hyh.shiyanshiguanli.service.LibService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author hyh
 * @version 1.0
 */
@Service
@SuppressWarnings({"ALL"})
public class LibServiceImpl implements LibService {

    @Autowired
    LibMapper libMapper;

    @Override
    public LibVO page(LibDTO libDTO) {

        List<Lib> libs = libMapper.page(libDTO);
        int size = libs.size();
        LibVO libVO = new LibVO();
        libVO.setLibManagers(libs);
        libVO.setTotal(size);
        return libVO;
    }

    @Override
    public void add(LibAddDTO libAddDTO) {
        libMapper.add(libAddDTO);
    }

    @Override
    public Lib selectById(Integer id) {
      return  libMapper.selectById(id);
    }

    @Override
    public void updateById(LibUpdateDTO libUpdateDTO) {
        libMapper.updateById(libUpdateDTO);
    }

    @Override
    public int deleteById(Integer id) {
        libMapper.deleteById(id);
        return MessageConstant.SUCCESS;
    }
}
